﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data;
using QuanLyRapChieuPhim.DTO;

namespace QuanLyRapChieuPhim.DAO
{
    class TTMuaVeDAO
    {
        DataProvider dp = new DataProvider();

        public BindingList<TTMuaVeDTO> GetList_QL()
        {

            DataTable dt = new DataTable();
            BindingList<TTMuaVeDTO> ds = new BindingList<TTMuaVeDTO>();
            if (dp.OpenConnect())
            {
                dt = dp.SqlExcuteQuery("uproc_GetList_TTMuaVe_QL", null);
                dp.CloseConnect();
                foreach (DataRow row in dt.Rows)
                {
                    TTMuaVeDTO DTO = new TTMuaVeDTO();
                    DTO.MaTTMuaVe = int.Parse(row["MaTTMuaVe"].ToString());
                    DTO.MaVe = int.Parse(row["MaVe"].ToString());
                    DTO.MaKhachHang = int.Parse(row["MaKhachHang"].ToString());
                    DTO.MaSuatChieu = int.Parse(row["MaSuatChieu"].ToString());
                    DTO.HangGhe = int.Parse(row["HangGhe"].ToString());
                    DTO.DayGhe = int.Parse(row["DayGhe"].ToString());
                    DTO.GiaVe = int.Parse(row["GiaVe"].ToString());

                    DTO.TenKhachHang = row["TenKhachHang"].ToString();
                    DTO.CMND = row["CMND"].ToString();
                    DTO.GioiTinh = (row["gioiTinh"].ToString() == "True") ? "Nam" : "Nữ";
                    DTO.DiaChi = row["DiaChi"].ToString();
                    DTO.DienThoai = row["DienThoai"].ToString();
                    DTO.TenSuatChieu = row["TenSuat"].ToString();
                    DTO.DaXoa = int.Parse(row["DaXoa"].ToString());

                    ds.Add(DTO);
                }
                return ds;
            }
            return null;
        }

        public BindingList<TTMuaVeDTO> GetList_QL_DaXoa()
        {

            DataTable dt = new DataTable();
            BindingList<TTMuaVeDTO> ds = new BindingList<TTMuaVeDTO>();
            if (dp.OpenConnect())
            {
                dt = dp.SqlExcuteQuery("uproc_GetList_TTMuaVe_QL_DaXoa", null);
                dp.CloseConnect();
                foreach (DataRow row in dt.Rows)
                {
                    TTMuaVeDTO DTO = new TTMuaVeDTO();
                    DTO.MaTTMuaVe = int.Parse(row["MaTTMuaVe"].ToString());
                    DTO.MaVe = int.Parse(row["MaVe"].ToString());
                    DTO.MaKhachHang = int.Parse(row["MaKhachHang"].ToString());
                    DTO.MaSuatChieu = int.Parse(row["MaSuatChieu"].ToString());
                    DTO.HangGhe = int.Parse(row["HangGhe"].ToString());
                    DTO.DayGhe = int.Parse(row["DayGhe"].ToString());
                    DTO.GiaVe = int.Parse(row["GiaVe"].ToString());

                    DTO.TenKhachHang = row["TenKhachHang"].ToString();
                    DTO.CMND = row["CMND"].ToString();
                    DTO.GioiTinh = (row["gioiTinh"].ToString() == "True") ? "Nam" : "Nữ";
                    DTO.DiaChi = row["DiaChi"].ToString();
                    DTO.DienThoai = row["DienThoai"].ToString();
                    DTO.TenSuatChieu = row["TenSuat"].ToString();
                    DTO.DaXoa = int.Parse(row["DaXoa"].ToString());

                    ds.Add(DTO);
                }
                return ds;
            }
            return null;
        }

    }
}
